<?php

class Create extends Controller {
	
	function Create() {
		parent::Controller();
	}

	function index() {
		if( !$this->Account->is_admin() ) {
			redirect( '', 'location');
		}
		if( isset($_POST['submit']) ) {
			$title = trim($this->input->post('title'));
			$description = trim($this->input->post('description'));
		
			if(empty($title)) {
				$this->error = 'Enter a title';
			} else if( empty($description) ) {
				$this->error = 'Enter a description';
			} else {
				$this->Projects->create($title, $description);
				redirect('project/view', 'location');
			}
		}
		$this->load->view('project/create');
	}

}

?>
